<!DOCTYPE html>
<html ng-app="app">
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body ng-controller="mCtrl as ctrl">
		<form ng-submit="ctrl.submit()" name="myForm">
			<input type="text" name="uname" ng-model="ctrl.user.username" required="required" ng-minlength="4"/><br />
			<span ng-show="myForm.uname.$error.required">This is a required field</span><br />
			<span ng-show="myForm.uname.$error.minlength">Minimum length required is 4</span><br />
			<span ng-show="myForm.uname.$invalid">This field is invalid</span><br />
			<input type="password" name="pwd" ng-model="ctrl.user.password" required="required" /><br />
			<span ng-show="myForm.pwd.$error.required">This is a required field</span><br />
			<input type="submit" value="submit" ng-disabled="myForm.$invalid"/>
		</form>
	</body>
	<script src="js/angular.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		angular.module('app', [])
		.then('mCtrl', [function(){
			var self = this;
			self.submit = function() {
				console.log(self.user);
			};
		}]);
		
	</script>
</html>
